//
//  EnvironmentConfigure.m
//  Pitch
//
//  Created by zhujinhui on 14-9-3.
//  Copyright (c) 2014年 zhujinhui. All rights reserved.
//

#import "EnvironmentConfigure.h"
#import "UIColor+Hex.h"

@implementation EnvironmentConfigure


static EnvironmentConfigure *instance = nil;

+(EnvironmentConfigure *) shareInstance{
    if (!instance) {
        instance = [[EnvironmentConfigure alloc]init];
    }
    return instance;
}

/**
 *get city name
 */
-(NSString *)getCityName{
    NSString *cityName = nil;
    @try {
         cityName = [[NSUserDefaults standardUserDefaults]objectForKey:LOCATION];
        return cityName;
    }
    @catch (NSException *exception) {
        NSLog(@"exception:%@",exception);
    }
    return cityName;
}


/**
 *set city name
 */
-(BOOL)setCityName:(NSString *) cityName{
    BOOL setSuccess = FALSE;

    if (cityName) {
        //judge if the city name contains "市"，if contains ,we should remove it frm cityname
        NSRange range = [cityName rangeOfString:@"市"];
        NSString *resultCityName;
        if (range.length > 0) {
            resultCityName = [cityName substringToIndex:range.location];
        }
        //set city infomation to user defaults
        @try {
            
            [[NSUserDefaults standardUserDefaults]setObject:resultCityName forKey:LOCATION];
            setSuccess = TRUE;
        }
        @catch (NSException *exception) {
            setSuccess = FALSE;
            NSLog(@"exception:%@",exception);
        }
    }else{
        NSLog(@"set city failed");
    }
    
    return setSuccess;
}


+(void)tabbarColorNavbarColor{
    UINavigationBar * appearance = [UINavigationBar appearance];
    [appearance setBarTintColor:[UIColor colorWithHex:0xfafaff]];
    //register to weixin
    UITabBar * appearance1 = [UITabBar appearance];
    [appearance1 setBarTintColor:[UIColor colorWithHex:0xfafaff]];
    
    UITabBarItem *appearance3 = [UITabBarItem appearance];
    [appearance3 setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                         [UIColor colorWithHex:0x3d6370], UITextAttributeTextColor,
                                         nil] forState:UIControlStateNormal];
    [appearance3 setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                         [UIColor orangeColor], UITextAttributeTextColor,
                                         nil] forState:UIControlStateSelected];
    
}

+(NSArray *) allOfflineWorkType{
    return [NSArray arrayWithObjects:@"校园",@"导购",@"促销",@"传单",@"服务员",@"婚庆",@"其他", nil];
}

/**
 jiangsu:
 <option value="320100">南京</option>
 <option value="320200">无锡</option>
 <option value="320500">苏州</option>
 <option value="321000">扬州</option>
 <option value="320300">徐州</option>
 <option value="320400">常州</option>
 <option value="320600">南通</option>
 <option value="320700">连云港</option>
 <option value="320800">淮安</option>
 <option value="320900">盐城</option>
 <option value="321100">镇江</option>
 <option value="321200">泰州</option>
 <option value="321300">宿迁</option>
 
 <option value="330100">杭州</option>
 <option value="330200">宁波</option>
 <option value="330300">温州</option>
 <option value="330400">嘉兴</option>
 <option value="330500">湖州</option>
 <option value="330700">金华</option>
 <option value="330900">舟山</option>
 <option value="331000">台州</option>
 <option value="331100">丽水</option>
 <option value="330600">绍兴</option>
 
 <option value="440300">深圳</option>
 <option value="440100">广州</option>
 
 <option value="310000">上海</option>
 
 
 **/

+(CGRect)appFrame{
    CGRect r = [ UIScreen mainScreen ].applicationFrame;
    return r;
}

+(CGRect) screenSize{
    CGRect r = [ UIScreen mainScreen ].bounds;
    return r;
}

+(NSString *)MACADD{
    return @"kysonkyson";
}


@end
